package com.learn.thread;

import lombok.Synchronized;

/**
 * 模拟线程网络超时
 */
public class TestThreadSleep implements Runnable{
    int ticketNum=10;
    @Override
    public void run() {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        while (ticketNum>0){
            System.out.println("当前用户"+Thread.currentThread().getName()+"抢到了第"+ticketNum+"张票");
            ticketNum--;
        }

    }

    public static void main(String[] args) {
        TestThreadSleep testThreadSleep = new TestThreadSleep();
        new Thread(testThreadSleep,"小明").start();
        new Thread(testThreadSleep,"小红").start();
        new Thread(testThreadSleep,"黄牛").start();
    }
}
